#include <QApplication>
#include <QLabel>
#include <QProgressBar>
#include <QTranslator>
#include <QLibraryInfo>
#include <QIcon>
#include "photo_printer.h"

int main(int argc, char **argv)
{
    //高清屏幕自适应,适配990高DPI
    #if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
    #endif

    #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
    QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
    #endif

    QApplication a(argc, argv);
    QString locale = QLocale::system().name();
    QTranslator trans_global, trans_menu;
    QString qtTranslationsPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);// /usr/share/qt5/translations
    QString kylinPhotoPrinterTranslationsPath = "/usr/share/kylin-photo-printer/translations";

    if(!trans_global.load("kylin-photo-printer_" + locale + ".qm", kylinPhotoPrinterTranslationsPath))
        qDebug() << "Load translations file" <<QLocale() << "failed!";
    else
        a.installTranslator(&trans_global);

    if(!trans_menu.load("qt_" + locale + ".qm", qtTranslationsPath))
        qDebug() << "Load translations file" <<QLocale() << "failed!";
    else
        a.installTranslator(&trans_menu);
    // QLabel *c = new QLabel(nullptr);
    // c->setText(a.arguments().join(" "));
    // c->show();
    a.setWindowIcon(QIcon::fromTheme("kylin-photo-viewer"));
    QStringList ls = a.arguments();
    ls.removeAt(0);
    if (ls.size() > 0) {
        PhotoPrinter *p = new PhotoPrinter(ls);
    }
    a.exec();
}